<template>
	<div class="d">
		<h1>我是D组件</h1>
		<h4>{{username}}</h4>
	</div>
</template>

<script>
	export default {
		name:'D',
		data() {
			return {
				username:''
			}
		},
		mounted() {
			this.$bus.$on('get-username',(value)=>{
				this.username = value
			})
		},
		beforeDestroy() {
			this.$bus.$off('get-username')
		},
	}
</script>

<style scoped>
	.d{
		background-color: pink;
		padding: 20px;
	}
</style>